#pragma once
#include <cstdio>
#include <ctime>

#define INFO 1
#define WARNING 2
#define ERR 3
#define DEBUG 4
#define FATAL 5

#define LOG_LEVEL INFO

#define LOG(level, fmt, ...) do {\
    if(level < LOG_LEVEL) break;\
    time_t current_time = time(nullptr);\
    struct tm* time_info = localtime(&current_time);\
    char formatted_time[26];\
    strftime(formatted_time, sizeof(formatted_time), "%Y-%m-%d %H:%M:%S", time_info);\
    printf("[%s %s:%d] " fmt "\n", formatted_time, __FILE__, __LINE__, ##__VA_ARGS__);\
}while(0)

#define INFO_LOG(fmt, ...) LOG(INFO, fmt, ##__VA_ARGS__)
#define WARNING_LOG(fmt, ...) LOG(WARNING, fmt, ##__VA_ARGS__)
#define ERROR_LOG(fmt, ...)  LOG(ERR, fmt, ##__VA_ARGS__)
#define DEBUG_LOG(fmt, ...) LOG(DEBUG, fmt, ##__VA_ARGS__)
#define FATAL_LOG(fmt, ...) LOG(FATAL, fmt, ##__VA_ARGS__)
